 


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.lip6.struts.actionForm.AddContactValidationForm;
import org.lip6.struts.domain.DAOContact;

public class AddContactAction extends Action {
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		
		final AddContactValidationForm lForm = (AddContactValidationForm) form;

		final long id = lForm.getId();

			
		final String Nom = lForm.getNom();
		
		final String Prenom = lForm.getPrenom();
		
		final String Email = lForm.getEmail();
		
		final String Adresse = lForm.getAdresse();
		
		

		// pour cr?er  un nouveau  DAO 
		DAOContact bd = new DAOContact();
		String lError = bd.addContact(Nom,Prenom,Email,Adresse);


		
		if (lError == null) {
			return mapping.findForward("success");
		} else {
			JOptionPane.showMessageDialog(null,"on a une erreur du dao pour l'ajout en base de donn?es");;
			return mapping.findForward("error");
		}
	}
}
